package org.example.diet_compass.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.math.BigDecimal;

import lombok.Data;

/**
 * 商品项
 *
 * @TableName goods
 */
@TableName(value = "goods")
@Data
public class Goods implements Serializable {
    /**
     * 商品 ID
     */
    @TableId
    private String id;

    /**
     * 商品名称
     */
    private String name;

    /**
     * 商品描述
     */
    private String description;

    /**
     * 商品价格
     */
    private Double price;

    /**
     * 商品折扣
     */
    private BigDecimal discount;

    /**
     * 商品图片
     */
    private String picture;

    /**
     * 商品已下单数量，默认值为0
     */
    private Integer orderNum;

    /**
     * 所属的二级分类id
     */
    private String categoryChildId;

    /**
     * 平均分
     */
    private BigDecimal averageScore;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Goods other = (Goods) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
                && (this.getDescription() == null ? other.getDescription() == null :
                this.getDescription().equals(other.getDescription()))
                && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
                && (this.getDiscount() == null ? other.getDiscount() == null :
                this.getDiscount().equals(other.getDiscount()))
                && (this.getPicture() == null ? other.getPicture() == null :
                this.getPicture().equals(other.getPicture()))
                && (this.getOrderNum() == null ? other.getOrderNum() == null :
                this.getOrderNum().equals(other.getOrderNum()))
                && (this.getCategoryChildId() == null ? other.getCategoryChildId() == null :
                this.getCategoryChildId().equals(other.getCategoryChildId())
                && (this.getAverageScore() == null ? other.getAverageScore() == null :
                        this.getAverageScore().equals(other.getAverageScore())));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
        result = prime * result + ((getDiscount() == null) ? 0 : getDiscount().hashCode());
        result = prime * result + ((getPicture() == null) ? 0 : getPicture().hashCode());
        result = prime * result + ((getOrderNum() == null) ? 0 : getOrderNum().hashCode());
        result = prime * result + ((getCategoryChildId() == null) ? 0 : getCategoryChildId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", desc=").append(description);
        sb.append(", price=").append(price);
        sb.append(", discount=").append(discount);
        sb.append(", picture=").append(picture);
        sb.append(", orderNum=").append(orderNum);
        sb.append(", categoryChildId=").append(categoryChildId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}